from App.ext import db
from App.models import BaseModel
from App.models.cinema_admin.cinema_hall_movie_model import HallMovie
from App.models.movie_user import MovieUser

ORDER_STATUS_NOT_PAY = 0
ORDER_STATUS_PAID_BUT_NOT_GET = 1
ORDER_STATUS_GET = 2
ORDER_STATUS_TIMEOUT = 3

# 高并发问题
class MovieOrder(BaseModel):
    # o_user_id = db.Column(db.Integer , db.ForeignKey("movie_user.id"))      # 直接用表名.字段名作字符串也行，这样不需要导包
    o_user_id = db.Column(db.Integer , db.ForeignKey(MovieUser.id))
    o_hall_movie_id = db.Column(db.Integer , db.ForeignKey(HallMovie.id))
    o_time = db.Column(db.DateTime)
    o_status = db.Column(db.Integer , default=ORDER_STATUS_NOT_PAY)     # 订单超时状态不用依靠定时器去一个对一个地修改，浪费资源。用户查询什么，想买什么位置买不到了再改
    o_seats = db.Column(db.String(128))
    o_price = db.Column(db.Integer , default = 99)
